#include "tcpserverthread.h"

#include <cassert>
#include <QTcpSocket>

TcpServerThread::TcpServerThread(QObject *parent) :
    QThread(parent)
{
}

TcpServerThread::~TcpServerThread()
{
	delete m_ServerSocket;
}

void TcpServerThread::run()
{
	m_ServerSocket = new QTcpServer;
	m_ServerSocket->listen(QHostAddress::Any, s_ServerPort);
	while(true)
	{
		if(m_ServerSocket->waitForNewConnection(-1))
		{
			while(m_ServerSocket->hasPendingConnections())
			{
				QTcpSocket *newSocket = m_ServerSocket->nextPendingConnection();
				emit(newConnectionComming(newSocket));

			}
		}
	}
}
